<?php if (!defined('THINK_PATH')) exit(); /*a:5:{s:33:"./public/admin/articleUpdate.html";i:1541559489;s:35:"./public/admin/common/head_css.html";i:1539594859;s:33:"./public/admin/common/header.html";i:1542002142;s:31:"./public/admin/common/left.html";i:1540969360;s:29:"./public/admin/common/JS.html";i:1542093076;}*/ ?>
<!doctype html>
<html>
<head>
    <meta charset="UTF-8"/>
    <title><?php echo $auth_name; ?></title>
    <!-- Mobile Specific Meta -->
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <!-- Favicon-->
    <link rel="shortcut icon" href="/public/static/img/fav.png">
    <!-- Author Meta -->
    <meta name="author" content="colorlib">
    <!-- Meta Description -->
    <meta name="description" content="">
    <!-- Meta Keyword -->
    <meta name="keywords" content="">
    <!-- meta character set -->
    <meta charset="UTF-8">

    <link href="https://fonts.googleapis.com/css?family=Poppins:100,200,400,300,500,600,700" rel="stylesheet">
    <!--
    CSS
    ============================================= -->
    <link rel="stylesheet" href="/public/static/css/linearicons.css">
    <link rel="stylesheet" href="/public/static/css/font-awesome.min.css">
    <!--<link rel="stylesheet" href="/public/static/css/bootstrap.css">-->
    <link rel="stylesheet" href="/public/static/css/owl.carousel.css">
    <link rel="stylesheet" href="/public/static/css/main.css">

    <link rel="stylesheet" type="text/css" href="/public/static/admin/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="/public/static/admin/css/main.css"/>
    <link href="/public/static/plug/layui/css/layui.css" rel="stylesheet" />
</head>
<body>

<header class="default-header">
<div class="topbar-wrap white">
    <div class="topbar-inner clearfix" style="background-color: #ffffff">
        <div class="topbar-logo-wrap clearfix">
            <h1 class="topbar-logo none"><a href="#" class="navbar-brand">后台管理</a></h1>
            <ul class="navbar-list clearfix">
                <li>
                    <a class="navbar-brand" href="index.html">
                        <img src="/public/static/img/logo.png" alt="">
                    </a>
                </li>
                <li><a href="#"  onclick="user_index()" target="_blank">首页</a></li>
            </ul>
        </div>
        <div class="top-info-wrap">
            <ul class="top-info-list clearfix">
                <li><a href="#" onclick="write_blog()">发表</a></li>
                <li><a href="#" onclick="person()">个人中心</a></li>
                <li><a href="#" onclick="logout()">退出</a></li>
                <li>
                    <img src="/<?php echo $admin_info['img']; ?>" style="margin-left: 5px;width: 30px;height: 30px; border-radius: 50%; -moz-border-radius: 50%;-webkit-border-radius: 50%;">
                </li>
                <li style="margin-top: -10px"><font size="1px"><?php echo $admin_info['username']; ?></font></li>
            </ul>
        </div>
    </div>
</div>
</header>
<div class="container clearfix">
    <div class="sidebar-wrap">
    <div class="sidebar-title" >
        <p style="padding-top: 2px;padding-left: 40px" >菜单</p>
    </div>
    <?php if(is_array($auth_infoA) || $auth_infoA instanceof \think\Collection || $auth_infoA instanceof \think\Paginator): $i = 0; $__LIST__ = $auth_infoA;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?>
    <div class="sidebar-content" >
        <ul class="sidebar-list" style="background-color: #74e1ee">
            <li>
                <a href="#" onclick=expand(<?php echo $v['auth_id']; ?>)><i class="icon-font">&#xe003;</i><?php echo $v['auth_name']; ?></a>
                <?php if(is_array($auth_infoB) || $auth_infoB instanceof \think\Collection || $auth_infoB instanceof \think\Paginator): $i = 0; $__LIST__ = $auth_infoB;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vv): $mod = ($i % 2 );++$i;if($vv['auth_pid'] == $v['auth_id']): ?>
                <ul class="sub-menu">
                    <li>
                        <a href="../<?php echo $vv['auth_c']; ?>/<?php echo $vv['auth_a']; ?>" id="child<?php echo $v['auth_id']; ?>" style="display: none">
                            <i class="icon-font">&#xe008;</i><?php echo $vv['auth_name']; ?></a>
                    </li>
                </ul>
                <?php endif; endforeach; endif; else: echo "" ;endif; ?>
            </li>
        </ul>
    </div>
    <?php endforeach; endif; else: echo "" ;endif; ?>
</div>
    <!--/sidebar-->
    <div class="main-wrap">
        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="/jscss/admin/design/">首页</a><span class="crumb-step">&gt;</span><a class="crumb-name" href="/jscss/admin/design/">作品管理</a><span class="crumb-step">&gt;</span><span>新增作品</span></div>
        </div>
        <div class="result-wrap">
            <div class="result-content">
                <form action="" method="post" id="myform" name="myform" enctype="multipart/form-data">
                    <table class="insert-tab" width="100%">
                        <tbody>
                        <tr>
                            <th width="120"><i class="require-red">*</i>分类：</th>
                            <td>
                                <select name="colId" id="catid" class="required">
                                    <?php if(is_array($write) || $write instanceof \think\Collection || $write instanceof \think\Paginator): $i = 0; $__LIST__ = $write;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$w): $mod = ($i % 2 );++$i;if($w['pid'] == 0 and $w['del'] == 1): ?>
                                    <option value="<?php echo $w['id']; ?>"><?php echo $w['title']; ?></option>
                                    <?php endif; endforeach; endif; else: echo "" ;endif; ?>
                                </select>
                            </td>
                        </tr>
                            <tr>
                                <th><i class="require-red">*</i>标题：</th>
                                <td>
                                    <input class="common-text required" id="title" name="title" size="50" value="" type="text">
                                </td>
                            </tr>

                            <tr>
                                <th><i class="require-red">*</i>缩略图：</th>
                                <td>
                                    <input name="token" id="token" value="FFFX123456" type="hidden">
                                    <button type="button" class="layui-btn" id="test1">
                                        <i class="layui-icon">&#xe67c;</i>上传图片
                                    </button>
                                    <em  id="a">

                                    </em>

                                </td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>内容：</th>
                                <td><textarea name="content" class="common-textarea" id="content" cols="30" style="width: 98%;display: none" rows="10"></textarea></td>
                            </tr>
                            <tr>
                                <th></th>
                                <td>
                                    <input class="btn btn-primary btn6 mr10" value="提交" id="edit_btn"  type="submit" lay-submit="" lay-filter="edit_btn">
                                    <!--<button class="btn btn-primary btn6 mr10" id="add-btn" lay-submit="" lay-filter="add-btn">-->
                                    <input class="btn btn6" onClick="history.go(-1)" value="返回" type="button">
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </form>
            </div>
        </div>

    </div>
    <!--/main-->
</div>
</body>
<script src="/public/static/js/vendor/jquery-2.2.4.min.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="/public/static/js/vendor/bootstrap.min.js"></script>
<script src="/public/static/js/jquery.ajaxchimp.min.js"></script>
<script src="/public/static/js/parallax.min.js"></script>
<script src="/public/static/js/owl.carousel.min.js"></script>
<script src="/public/static/js/jquery.magnific-popup.min.js"></script>
<script src="/public/static/js/jquery.sticky.js"></script>
<script src="/public/static/js/main.js"></script>

<script src="/public/static/plug/layui/layui.js" type="text/javascript" charset="utf-8"></script>

<script src="/public/static/js/user/jump.js"></script>
<script src="/public/static/js/user/func.js"></script>
<script src="/public/static/js/user/compose_list.js"></script>
<script src="/public/static/js/user/url.js"></script>

<script src="/public/static/js/common/base64.js"></script>
<script src="/public/static/js/common/json.js"></script>
<script src="/public/static/js/common/md5.js"></script>
<script src="/public/static/js/common/sign.js"></script>
<script>
    var id = location.href.split('/').pop(); //获取url中"/"符后的字串
    console.log(id);
    var layedits = [];
    var img = [];
    getEditData(id);

    layui.use('layedit', function(data){
        var layedit = layui.layedit;
        var token ='FFFX123456';
         layedit.set({
             uploadImage:{
                 url: url_list.upload,
                 data:{'token':token},
                 type:'post',
             }
         });
        layedits.push(layedit.build('content')); //建立编辑器
    });

    layui.use('upload', function(){
        var upload = layui.upload;
        //执行实例
        upload.render({
            elem: '#test1' //绑定元素
            ,url:url_list.upload //上传接口
            ,data:{'token':'FFFX123456'}
            ,done: function(res){
                //上传完毕回调
                console.log(res);
                img.push(res.data.savepath);
                layer.msg(res.msg, {icon: 1, time: 1500});
                $("#a").html('<img style="height: 25px" src="/public/static/images/check.png" >');
            }
            ,error: function(){
                //请求异常回调
                layer.msg(res.msg, {icon: 2, time: 1500});

            }
        });
    });

    layui.use(['form'],function () {
        var form = layui.form;
        form.on('submit(edit_btn)', function(data) {
            var content = layui.layedit.getContent(layedits[0]);
            var title = $('#title').val();
            var pid = $('#catid').val();
            //验证签名
            sign.params = {
                id:id,
                pid: pid,
                title: title,
                content: content,
                img: img[0]
            }
            var encode_data = sign.encode_post();
            console.log(encode_data);
            $.post(url_list.rewriting,encode_data,function (data) {
                //解码
                if(typeof data == 'string'){
                    data = eval('('+data+')');
                }
                data = sign.decode_post(data);
                console.log(data);
                if (data.code == 200) {
                    layer.msg(data.msg, {icon: 1, time: 1500});
                    myArticleList();
                } else {
                    layer.msg(data.msg, {icon: 2});
                }
            });
            return false;
        });
    });

    //获取内容并替换textarea的内容
    function getEditData(id) {
        //验证签名
        sign.params = {
            id: id
        };
        var encode_data = sign.encode_post();
        $.post(url_list.one_compose,encode_data,function(data){
            //解码
            if(typeof data == 'string'){
                data = eval('('+data+')');
            }
            data = sign.decode_post(data);
            console.log(data);
            document.getElementById("title").value = data.data.title;
            layui.layedit.setContent(layedits[0], data.data.content);
        })
    }

</script>
</html>